<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>用 JSON 字符串创建对象</h1>

<p id="demo"></p>
<script>
    var text = '{ "employees" : [' +
        '{ "firstName":"Bill" , "lastName":"Gates" },' +
        '{ "firstName":"Steve" , "lastName":"Jobs" },' +
        '{ "firstName":"Alan" , "lastName":"Turing" } ],"age" : 18}';
    var arr=JSON.parse(text);
    document.getElementById('demo').innerHTML = arr.employees[0].firstName+" "+arr.employees[1].firstName+" "+
    arr.age;
</script>

</body>
</html>